export default [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../../views/home/Home'),
    meta: {
      isShowFooter: true
    }
  },
  {
    path: '/detail/:shopId?',
    name: 'Detail',
    component: () => import('../../views/detail/Detail'),
    meta: {
      isShowFooter: true
    },
    props: true
  },
  {
    path: '/search/:keyword?',
    name: 'Search',
    component: () => import('../../views/search/Search'),
    meta: {
      isShowFooter: true
    },
    props: true
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../../views/register/Register'),
    meta: {
      isShowFooter: false
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../../views/login/Login'),
    meta: {
      isShowFooter: false
    }
  },
  {
    path: '/addcartsuccess',
    name: 'AddCartSuccess',
    component: () => import('../../views/addCartSuccess/AddCartSuccess'),
    meta: {
      isShowFooter: true
    }
  },
  {
    path: '/cart',
    name: 'Cart',
    component: () => import('../../views/cart/Cart'),
    meta: {
      isShowFooter: true
    }
  },

  {
    path: '/trade',
    name: 'Trade',
    component: () => import('../../views/trade/Trade'),
    meta: {
      isShowFooter: true
    },
    beforeEnter: (to, from, next) => {
      // 只允许从交易页面跳过来
      from.path === '/cart' ? next() : next(false)
    }
  },
  {
    path: '/pay/:orderId',
    name: 'Pay',
    props: true,
    component: () => import('../../views/pay/Pay'),
    meta: {
      isShowFooter: true
    },
    beforeEnter: (to, from, next) => {
      // 只允许从交易页面跳过来
      from.path === '/trade' ? next() : next(false)
    }
  },
  {
    path: '/paysuccess',
    name: 'PaySuccess',
    props: true,
    component: () => import('../../views/paySuccess/PaySuccess'),
    meta: {
      isShowFooter: true
    },
    beforeEnter: (to, from, next) => {
      // 只允许从交易页面跳过来
      console.log(from)
      from.path.includes('/pay') ? next() : next(false)
    }
  },
  {
    path: '/center',
    redirect: '/center/profile',
    name: 'Center',
    props: true,
    component: () => import('../../views/center/Center'),
    meta: {
      isShowFooter: true
    },
    children: [
      {
        path: 'profile',
        component: () =>
          import('../../views/center/centerChildRoute/ProfileOrder')
      },
      {
        path: 'group',
        component: () =>
          import('../../views/center/centerChildRoute/GroupOrder')
      }
    ]
  }
]
